test(amber): add unit test coverage for Schedule iterator semantics#4562
Open
aglinxinyuan wants to merge 1 commit intoapache:mainfrom
Open
test(amber): add unit test coverage for Schedule iterator semantics#4562aglinxinyuan wants to merge 1 commit intoapache:mainfrom
aglinxinyuan wants to merge 1 commit intoapache:mainfrom
Conversation
### What changes were proposed in this PR? Add `ScheduleSpec` covering the iterator semantics of `Schedule`: - `getRegions` flattens all level sets across the map - Iteration order follows ascending level keys, starting from the minimum - `hasNext` / `next()` semantics including empty schedule, exhaustion, and non-zero starting level keys - Gap-stop behavior on non-contiguous level keys ### Any related issues, documentation, discussions? Closes apache#4561 ### How was this PR tested? `sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.scheduling.ScheduleSpec"` — 7/7 tests pass. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 4.7) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Yicong-Huang
approved these changes
Apr 30, 2026
Comment on lines
+77
to
+84
| it should "stop iteration at the first gap in level keys" in { | ||
| val r0 = region(0, "a") | ||
| val rGapped = region(2, "b") | ||
| val schedule = Schedule(Map(0 -> Set(r0), 2 -> Set(rGapped))) | ||
|
|
||
| assert(schedule.next() == Set(r0)) | ||
| assert(!schedule.hasNext) | ||
| } |
Contributor
There was a problem hiding this comment.
can we just disallow gaps?
Contributor
Author
There was a problem hiding this comment.
Good call. Added the contiguity invariant to Schedule itself in #4444 (commit 9472125) — it now requires level keys to be exactly 0..N-1, so gaps are no longer permitted. This test will need to be removed (and replaced with a require rejection test) once #4444 lands. I will update this PR to drop the gap/non-zero tests and add a rejection test.
Comment on lines
+86
to
+95
| it should "begin iteration from the minimum level when level keys do not start at zero" in { | ||
| val r3 = region(3, "a") | ||
| val r4 = region(4, "b") | ||
| val schedule = Schedule(Map(3 -> Set(r3), 4 -> Set(r4))) | ||
|
|
||
| assert(schedule.hasNext) | ||
| assert(schedule.next() == Set(r3)) | ||
| assert(schedule.next() == Set(r4)) | ||
| assert(!schedule.hasNext) | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Same — non-zero starting keys are now rejected by the require added to Schedule in #4444. Will follow up here once that lands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
Add
ScheduleSpeccovering the iterator semantics ofSchedule(amber/src/main/scala/org/apache/texera/amber/engine/architecture/scheduling/Schedule.scala):getRegionsflattens all level sets across the maphasNext/next()semantics including empty schedule, exhaustion, and non-zero starting level keysAny related issues, documentation, discussions?
Closes #4561
How was this PR tested?
sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.scheduling.ScheduleSpec"— 7/7 tests pass.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.7)